import React, { useEffect, useState } from "react";
function useScrollPosition() {
  const [scrollPosition, setscrollPosition] = useState(0);
  useEffect(() => {
    const handleScroll = () => {
      setscrollPosition(window.scrollY);
    };

    document.addEventListener("scroll", handleScroll);
    return () => {
      document.removeEventListener("scroll", handleScroll);
    };
  }, []);

  return scrollPosition;
}
export default useScrollPosition;
